﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Center.lib.utils.common
{
    public class StringUtil
    {
        public static bool NotBlank(String str)
        {
            if (String.IsNullOrEmpty(str))
            {
                return false;
            }
            if (String.IsNullOrEmpty(str))
            {
                return false;
            }
            return true;
        }
        public static String cutBetween(String src, String split)
        {
            try
            {
                int sIndex = src.IndexOf(split);
                String left = src.Substring(sIndex + 1);
                int endIndex = left.IndexOf(split);
                if (endIndex > 0)
                {
                    return left.Substring(0, endIndex);
                }
                else
                {
                    return string.Empty;
                }
            }
            catch (Exception e)
            {
                return string.Empty;
            }
        }
        public static String cutSize(String src, int size)
        {
            try
            {
                if (src.Length >= size)
                {
                    String left = src.Substring(0, size);
                    return left;
                }
                else
                {
                    String left = src;
                    for (int i = 0; i < size - src.Length; i++)
                    {
                        left += " ";
                    }
                    return left;
                }
            }
            catch (Exception e)
            {
                return string.Empty;
            }
        }

        public static String getUUID()
        {
            string id = System.Guid.NewGuid().ToString("N");
            return id;
        }
    }
}
